import service from '@/utils/request'

const BASE_URL = 'api-course'

// 获取班级列表
export function gradeList(data) {
    return service({
        url: `${BASE_URL}/classes`,
        method: 'get',
        params: data
    })
}

// 获取简单班级列表
export function gradeSimpleList(data) {
    return service({
        url: `${BASE_URL}/classes/simple`,
        method: 'get',
        params:data
    })
}

// 新增班级
export function addGrade(data) {
    return service({
        url: `${BASE_URL}/class`,
        method: 'post',
        data
    })
}

// 编辑未发布班级
export function editUnReleaseGrade(data) {
    return service({
        url: `${BASE_URL}/class/un-release/${data.classId}`,
        method: 'put',
        data
    })
}

// 删除班级
export function deleteGrade(gradeId) {
    return service({
        url: `${BASE_URL}/class/${gradeId}`,
        method: 'delete'
    })
}


// 课程列表
export function courseList(classId) {
    return service({
        url: `${BASE_URL}/courses/simple` + '?classId=' + classId,
        method: 'get'
    })
}

//教室列表
export function classRoomList(classRoomId) {
    return service({
        url: `${BASE_URL}/class-rooms/simple` + '?classRoomId=' + classRoomId,
        method: 'get'
    })
}

// 班级详情
export function classDetail(gradeId) {
    return service({
        url: `${BASE_URL}/class/${gradeId}`,
        method: 'get'
    })
}


//启用/停用
export function enableClass(gradeId) {
    return service({
        url: `${BASE_URL}/class/enable/${gradeId}`,
        method: 'put',
    })
}

//开始报名
export function signUpClass(gradeId) {
    return service({
        url: `${BASE_URL}/class/sign-up/${gradeId}`,
        method: 'put',
    })
}

//开班
export function beginClass(gradeId) {
    return service({
        url: `${BASE_URL}/class/begin/${gradeId}`,
        method: 'put',
    })
}

//更新教师
export function updateTeacher(data) {
    return service({
        url: `${BASE_URL}/class/teacher`,
        method: 'put',
        data
    })
}


//指定供应商
export function updateSupplier(data) {
    return service({
        url: `${BASE_URL}/class/supplier`,
        method: 'put',
        data
    })
}

// 课程班级课节列表
export function listCourseDate(classId) {
    return service({
        url: `${BASE_URL}/class/course-date/${classId}`,
        method: 'get'
    })
}


//出勤学生列表
export function listAttendance(classId, data) {
    return service({
        url: `${BASE_URL}/class/attendance/${classId}`,
        method: 'get',
        params: data
    })
}

//机构申请开班
export function applySchoolCourse(data) {
    return service({
        url: `${BASE_URL}/class/apply/school`,
        method: 'put',
        data
    })
}

//机构取消申请开班
export function applySchoolCourseCancel(classId) {
    return service({
        url: `${BASE_URL}/class/apply/school/cancel/${classId}`,
        method: 'delete',
    })
}

//学校发布班级
export function releaseGrade(data,classId) {
    return service({
        url: `${BASE_URL}/class/release/${classId}`,
        method: 'put',
        data
    })
}


//取消报名
export function signUpCancel(classId) {
    return service({
        url: `${BASE_URL}/class/sign-up-cancel/${classId}`,
        method: 'put',
    })
}

//拒绝申请
export function refuseApply(classId) {
    return service({
        url: `${BASE_URL}/class/refuse-apply/${classId}`,
        method: 'put',
    })
}

//运营/管理员修改
export function adminEditClass(data,classId) {
    return service({
        url: `${BASE_URL}//class/admin/${classId}`,
        method: 'put',
        data
    })
}
